package com.starbaba.statistics.utils;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("all")
public class StatisticsUtils {
    
    public static double formatNumbers(double amonut,int num,int type){
        double formatamt = 0d;
        BigDecimal decimal = new BigDecimal(amonut);
        if(org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(type)) && type==0){
            formatamt = decimal.setScale(num,decimal.ROUND_HALF_UP).doubleValue();
        }else{
            formatamt = decimal.setScale(num,decimal.ROUND_HALF_DOWN).doubleValue();
        }
        return formatamt;
    }

    public static float formatFloatNumbers(float amonut,int num,int type){
        float formatamt = 0f;
        BigDecimal decimal = new BigDecimal(amonut);
        if(org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(type)) && type==0){
            formatamt = decimal.setScale(num,decimal.ROUND_HALF_UP).floatValue();
        }else{
            formatamt = decimal.setScale(num,decimal.ROUND_HALF_DOWN).floatValue();
        }
        return formatamt;
    }
}